<template>
  <base-dialog v-bind="$attrs" v-on="$listeners" :title="title" @submit="submit" width="600px">
    <el-form ref="elForm" :model="formData" :rules="rules" size="medium" label-width="80px" >
      <el-form-item label="回访记录" prop="content">
        <el-input v-model="formData.content"></el-input>
      </el-form-item>
    </el-form>
  </base-dialog>
</template>
<script>
import BaseDialog from "@/components/Common/BaseDialog";
import list from "@/api/onlineRepair/list/index"

export default {
  name: "addRecodeDialog",
  components: {BaseDialog},
  props: {
    id: {
      type: String,
      default: undefined
    },
    row: {
      type: Object,
      default: function () {
        return {};
      }
    }
  },
  computed:{
    title() {
      return  this.row.id ? "编辑" : "新增";
    },
  },
  data() {
    return {
      formData:{
        content:undefined
      },
      rules: {
        content: [{
          required: true,
          message: '请输入正确的联系电话',
          trigger: 'blur'
        }]
      },

    }
  },
  created() {
    if(this.row.id){
      this.formData = {...this.row}
    }

  },
  methods: {
    submit() {
      if(this.row.id){
        list.editCallBack(this.id,this.formData.id,this.formData).then(res=>{
          this.msgSuccess(res.msg)
          this.$emit("reloadList")
          this.$emit("update:visible", false)
        })
      }else{
        list.addCallBack(this.id,this.formData).then(res=>{
          this.msgSuccess(res.msg)
          this.$emit("reloadList")
          this.$emit("update:visible", false)
        })
      }

    }
  }
}
</script>
<style lang="scss" scoped>
.addGoods{
  padding:15px 0;
  display: flex;
  justify-content: space-between;
  align-items: center;
  >span{
    color: #888;
  }
}
.goodList{
  ::v-deep .el-input-number--mini{
    width: 100px;
    margin-right: 15px;
  }
  li{
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding:10px 0;
    border-bottom:1px solid #eee;

  }

}
</style>
